<template>
  <van-nav-bar :title="title" @click-left="onClickLeft">
    <template #left>
      <van-space size="0.2rem" v-if="cityName"> {{ cityName }}<van-icon name="arrow-down"></van-icon></van-space>
      <van-space v-else><van-icon name="cross"></van-icon></van-space>
    </template>
    <template #right v-if="title === '影院'">
      <van-icon name="search" size="1.5rem" />
    </template>
  </van-nav-bar>
</template>
<script setup>

import { computed } from 'vue';
import { useStore } from "@/stores/index.js";
import { useRouter } from "vue-router";
const store = useStore();
// const cityName = ref('');
// cityName.value = store.cityName;

const cityName = computed(() => {

  if (store.cityName === "定位失败") {
    return ""
  } else {
    return store.cityName
  }
});

const router = useRouter();

defineProps({
  title: {
    type: String,
  }
})



const onClickLeft = () => {
  // 【非常重要】重置页码
  store.setPageNum(1)
  // 弹出定位页面
  router.push({ path: '/city' })

  // store.setTabIndex(0)
  // console.log("city-当前tabindex:", store.tabIndex);


};

</script>
